/*
 * Copyright (C) 2009 Rob Cash
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Transformer.java
 * 
 * Created on Jan 17, 2009 at 12:48:28 PM
 */

package org.robcash.apps.messagepopup.dataaccess.util;

import org.robcash.apps.messagepopup.MessageException;

/**
 * Transforms objects from a value object to a data access object and vice versa
 * @param <D> Data class
 * @param <V> Value object class
 * @author Rob
 */
public interface Transformer<D,V> {

    /**
     * Convert to a data object
     * @param valueObject Value object that should be converted to a data object
     * @return Data object
     * @throws MessageException Thrown when the value object cannot be
     * transformed to a data object
     */
    public D toDataObject(V valueObject) throws MessageException;

    /**
     * Convert to a value object
     * @param dataObject Data object that should be converted to a value object
     * @return Value object
     * @throws MessageException Thrown when the data object cannot be
     * transformed to a value object
     */
    public V toValueObject(D dataObject) throws MessageException;

}
